//
//  Utilities.h
//  HKOCRuler
//
//  Created by lbxia on 2018/11/23.
//  Copyright © 2018年 lbx. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <ARKit/ARKit.h>
#import "Utilities.h"


@class SCNVector3OBJ;

API_AVAILABLE(ios(11.0))
@interface UIImage (HKRuler)

@end


API_AVAILABLE(ios(11.0))
@interface WorldPostion : NSObject
@property (nonatomic, assign) SCNVector3 position;
@property (nonatomic, strong) ARPlaneAnchor *planeAnchor;
@property (nonatomic, assign) BOOL hitAPlane;
@end





API_AVAILABLE(ios(11.0))
@interface Utilities : NSObject

+ (CGFloat)distanceFromPos:(SCNVector3)from to:(SCNVector3)to;
+ (SCNPlane*)createPlaneWithSize:(CGSize)size contents:(id)contents;

+ (SCNNode*)createAxesNodeWithQuiverLength:(CGFloat)quiverLength
                           quiverThickness:(CGFloat)quiverThickness;




#pragma mark- SCNVector3常见处理
+ (SCNVector3)positionFromTransform:(matrix_float4x4)transform;

//长度
+ (CGFloat)SCNVector3Length:(SCNVector3)s;

//left - right 减号
+ (SCNVector3)SCNVector3Sub:(SCNVector3)left right:(SCNVector3)right;

//left + right 加号
+ (SCNVector3)SCNVector3Add:(SCNVector3)left right:(SCNVector3)right;

//left/right 除号
+ (SCNVector3)SCNVector3DiV:(SCNVector3)left right:(CGFloat)right;

//归化
+ (SCNVector3)SCNVector3Normalized:(SCNVector3)s;

//left * right 乘号
+ (SCNVector3)SCNVector3Product:(SCNVector3)left right:(CGFloat)right;

//left cross right
+ (SCNVector3)SCNVector3Cross:(SCNVector3)left right:(SCNVector3)vec;

+ (CGFloat)dot:(SCNVector3)left vec: (SCNVector3)vec;

//平均值
+ (SCNVector3)SCNVector3Average:(NSArray<SCNVector3OBJ*>*)list;


+ (SCNVector3OBJ*) rayIntersectionWithHorizontalPlane:(SCNVector3)rayOrigin
                                            direction:(SCNVector3)direction
                                               planeY:(CGFloat)planeY;


@end

//包装SCNVector3
API_AVAILABLE(ios(11.0))
@interface SCNVector3OBJ : NSObject

@property (nonatomic, assign) SCNVector3 s;
@property (nonatomic, assign) CGFloat x;
@property (nonatomic, assign) CGFloat y;
@property (nonatomic, assign) CGFloat z;

+ (SCNVector3OBJ*)objectWith:(SCNVector3)s;

@end

API_AVAILABLE(ios(11.0))
@interface SCNMaterial(HKRuler)

+ (SCNMaterial*)materialWithDiffuse:(id)diffuse respondsToLighting:(BOOL)respondsToLighting;

@end
